#pragma once

#include "CreateLinkAction.h"

#include "LinkEndCreationData.h"

namespace uml {

CreateLinkAction::CreateLinkAction(const QString& umlType)
    : WriteLinkAction(umlType) {}

void CreateLinkAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    WriteLinkAction::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(endDatas_, "endDatas", json, errorList);
}

void CreateLinkAction::toJson(QJsonObject& json) {
    WriteLinkAction::toJson(json);
    JsonSerializable::toJsonArray(endDatas_, "endDatas", json);
}

/// <summary>
/// endDatas getter
/// The LinkEndData that specifies the values to be placed on the Association ends
/// for the new link.
/// </summary>
vector<shared_ptr<LinkEndCreationData>>& CreateLinkAction::endDatas() {
    return endDatas_;
}

} // namespace uml
